package com.study.controller;

import com.study.entity.User;
import com.study.util.CacheUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MyController {

    @Autowired
    User user;

    @Autowired
    CacheUtil cacheUtil;

    @RequestMapping("/getUser")
    public User getUser(String name) {
        User user1 = cacheUtil.getUserByName(name);
        return user1;
    }

    @RequestMapping("/getUser1")
    public User getUser1(String name) {
        User tmp = new User();
        tmp.setName(name);
        User user1 = cacheUtil.getUser(tmp);

        return user1;
    }

    @RequestMapping("/saveUser")
    public String saveUser() {
        User user1 = cacheUtil.saveUser(user);
        return user1.toString();
    }
}
